@extends('layouts.app') @section('content')

<div class="container">
    <div class="row category-index">
        <div class="col-md-10 col-md-offset-1">
            <div class="row">
                <div class="col-md-8">
                    <div>
                        <div style="position:relative; margin-bottom: 30px;">
                            <img style="width: 80px; height:80px; border-radius:10px;" src="/lv5/public/img/category/{{ $category->category_img }}" alt="">
                            <div style="display: inline-block; vertical-align: middle; margin-left: 12px;">
                                <p>{{ $category->name }}</p>
                                <p>
                                    <span>收录了 {{ $category->page_num }} 篇文章</span>,
                                    <span> {{$category->follower_total}} 人关注</span>
                                </p>
                            </div>
                            @if (Auth::guest())
                            <a style="position:absolute; margin-left:50px;margin-top:20px;" href="{{ url('/login') }}" class="btn btn-primary">+ 关注</a> @elseif ($category->founder == Auth::user()->id)
                            <button class="btn btn-primary" disabled style="position:absolute; margin-left:50px;margin-top:20px;">已关注</button> @else
                            <?php $user_array = explode(',', $category->follower); ?>
                            <?php $b = 1; ?> @foreach ($user_array as $user_id ) @if ($user_id == Auth::user()->no_id )
                            <a style="position:absolute; margin-left:50px;margin-top:20px;" href="{{ url('category/unfollow?category='.$category->id) }}"
                                class="btn btn-primary">已关注</a>
                            <?php $b = 0; ?> @endif @endforeach @if($b == 1)
                            <a style="position:absolute; margin-left:50px;margin-top:20px;" href="{{ url('category/follow?category='.$category->id) }}"
                                class="btn btn-primary">+ 关注</a> @endif @endif
                        </div>
                    </div>
                    @foreach ($articles as $article)
                    <hr style="margin: 5px 0; width:100%; height:5px;">
                    <li style="margin: 40px 0; list-style:none;">
                        <div class="row">
                            <div class="col-md-8 col-xs-7">
                                @foreach ($article->hasManyUsers as $user)
                                <img style="width: 32px; height:32px; border-radius: 16px;" src="/lv5/public/img/user/{{ $user->avatar }}" alt="">
                                <span>{{ $user->name }}</span>&nbsp;&nbsp;&nbsp;&nbsp;
                                <span>发表于&nbsp;&nbsp;{{ $article->created_at }}</span> @endforeach
                                <div class="title">
                                <h4><a class="article-title" href="{{ url('article/'.$article->id) }}">
                                        {{ $article->title }}
                                    </a></h4>
                                </div>
                                <div class="body">
                                    <p>{{ mb_substr($article->body, 0, 50).'...'}}</p>
                                </div>
                                <div style="">
                                    <span style="border: 1px solid #F1907F; padding: 2px 5px; border-radius: 3px; color:#F1907F; ">{{ $article->category }}</span> &nbsp;&nbsp;&nbsp;阅读&nbsp;(
                                    <span>{{ $article->read_total}}</span>) &nbsp;&nbsp;&nbsp;回复&nbsp;
                                    <span>{{ $article->reply_total }}</span> &nbsp;&nbsp;&nbsp;点赞&nbsp;
                                    <span>{{ $article->upvote_total }}</span>
                                </div>
                            </div>
                            <div class="col-md-4 col-xs-5">
                                <a href="">
                                    <img class="img-responsive" style="width:200px; height: 150px;border-radius:12px;" src="/lv5/public/img/cover/{{$article->cover_img}}"
                                        alt="">
                                </a>
                            </div>
                        </div>
                    </li>
                    @endforeach
                </div>
                <div class="col-md-4">
                    <p style="margin-top:12px;">专题公告</p>
                    <p style="width:95%; word-break:break-all;">{{ $category->intro }}</p>
                    <hr style="width: 92%;">
                    <div>
                        <p>管理员</p>
                        <img style="width:40px; height:40px; border-radius: 20px;" src="/lv5/public/img/user/{{ $founder->avatar }}" alt="">
                        <div style="display:inline-block;">
                        </div>
                        <span>{{ $founder->name }}</span>
                        <span class="identity">创建者</span>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>

@endsection